import CryptoJS from 'crypto-js'
// 默认的 KEY
const KEY = CryptoJS.enc.Utf8.parse('cn2u39dbcnqiowap')
/**
* AES加密 ：字符串 key
*/
export function Encrypt (word, keyStr) {
  let key = KEY
  if (keyStr) {
    key = CryptoJS.enc.Utf8.parse(keyStr)
  }
  let srcs = CryptoJS.enc.Utf8.parse(JSON.stringify(word))
  let encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
  return encrypted.toString()
}
